package com.ruoyi.teacher.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.Degree;
import com.ruoyi.teacher.service.IDegreeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学历学位信息Controller
 * 
 * @author xiangzy
 * @date 2022-05-08
 */
@RestController
@RequestMapping("/teacher/degree")
public class DegreeController extends BaseController
{
    @Autowired
    private IDegreeService degreeService;

    /**
     * 查询学历学位信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:degree:list')")
    @GetMapping("/list")
    public TableDataInfo list(Degree degree)
    {
        startPage();
        List<Degree> list = degreeService.selectDegreeList(degree);
        return getDataTable(list);
    }

    /**
     * 导出学历学位信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:degree:export')")
    @Log(title = "学历学位信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Degree degree)
    {
        List<Degree> list = degreeService.selectDegreeList(degree);
        ExcelUtil<Degree> util = new ExcelUtil<Degree>(Degree.class);
        return util.exportExcel(list, "degree");
    }

    /**
     * 获取学历学位信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:degree:query')")
    @GetMapping(value = "/{recordid}")
    public AjaxResult getInfo(@PathVariable("recordid") Long recordid)
    {
        return AjaxResult.success(degreeService.selectDegreeById(recordid));
    }

    /**
     * 新增学历学位信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:degree:add')")
    @Log(title = "学历学位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Degree degree)
    {
        return toAjax(degreeService.insertDegree(degree));
    }

    /**
     * 修改学历学位信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:degree:edit')")
    @Log(title = "学历学位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Degree degree)
    {
        return toAjax(degreeService.updateDegree(degree));
    }

    /**
     * 删除学历学位信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:degree:remove')")
    @Log(title = "学历学位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordids}")
    public AjaxResult remove(@PathVariable Long[] recordids)
    {
        return toAjax(degreeService.deleteDegreeByIds(recordids));
    }
}
